package org.hs.phd.odi.tracking.tracker.opencvmeanshift;

import org.hs.phd.odi.tracking.tracker.trackwindow.RegularGridPolygonalTrackWindow;

import com.googlecode.javacv.cpp.opencv_core;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_imgproc.CvConnectedComp;
import com.googlecode.javacv.cpp.opencv_video;

public class OpenCvCAMshiftTracker extends OpenCvMeanshiftTracker {

	public OpenCvCAMshiftTracker(){
		super( new RegularGridPolygonalTrackWindow() );
	}
	
	protected opencv_core.CvBox2D findBestMatchTrack( IplImage backprojection, 
	  opencv_core.CvRect trackWindow )
	{
		
		opencv_core.CvBox2D trackingResult = new opencv_core.CvBox2D();
		CvConnectedComp comp = new CvConnectedComp();
		opencv_video.cvCamShift(backprojection, trackWindow, 
				opencv_core.cvTermCriteria(opencv_core.CV_TERMCRIT_EPS | opencv_core.CV_TERMCRIT_ITER, 10, 1), comp, 
				trackingResult);
		
		return trackingResult;

	}

	@Override
	public String getName() {
		return "Backprojection CAMshift Tracker";
	}

}
